﻿using K9Nano.Domain.Entities;

namespace K9Nano.Domain.Authentication;

public interface IUserManager<TUser, TRole>
    where TUser : UserBase
    where TRole : RoleBase
{
    Task<TUser> CreateAsync(TUser user, CancellationToken cancellation);
    Task<TUser> UpdateAsync(TUser user, CancellationToken cancellation);
    Task<bool> DeleteAsync(TUser user, CancellationToken cancellation);
    Task AddRolesAsync(TUser user, IEnumerable<TRole> roles, CancellationToken cancellation);
    Task RemoveRolesAsync(TUser user, IEnumerable<TRole> roles, CancellationToken cancellation);
    Task SetStatusAsync(TUser user, bool isEnabled, CancellationToken cancellation);
    Task<string?> GetNameAsync(long id, CancellationToken cancellation);
    Task<TUser?> FindByNameAsync(string username, CancellationToken cancellation);
    Task<TUser?> FindByIdAsync(long id, CancellationToken cancellation);
    Task<TUser?> FindByPasswordAsync(string username, string password, CancellationToken cancellation);
    Task<string[]> GetRolesAsync(long userId, CancellationToken cancellation);
    Task SetOrganizationAsync(long id, long organizationId, CancellationToken cancellation);
    Task<ApiResponse> ChangePasswordAsync(long id, string oldPassword, string newPassword, CancellationToken cancellation);
}